package com.icongyou.enterprise.talent_analysis.listener;

import com.icongyou.enterprise.talent_analysis.service.WordCloudService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 词云图更新触发器
 * 监听评分变化，自动触发词云图更新
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class WordCloudUpdateTrigger {
    
    private final WordCloudService wordCloudService;
    
    /**
     * 当教师添加/修改评语时触发
     * @param studentId 学生ID
     * @param gradeId 评分ID
     */
    public void onCommentChanged(String studentId, String gradeId) {
        wordCloudService.generateWordCloudAsync(studentId, "comment_updated", gradeId);
    }
    
    /**
     * 手动触发词云图更新
     * @param studentId 学生ID
     */
    public void manualTrigger(String studentId) {
        wordCloudService.generateWordCloudAsync(studentId, "manual", null);
    }
}
